{extend name='common/content' /}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <button data-modal='{:url("$classuri/add")}' data-title="添加栏目" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加栏目</button>
    <button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除栏目</button>
</div>
{/block}

{block name="content"}

<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <table class="table table-hover">
        <thead>
            <tr>
                <th class='list-table-check-td'>
                    <input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
                </th>
                <th class='list-table-sort-td'>
                    <button type="submit" class="layui-btn layui-btn-normal layui-btn-mini">排 序</button>
                </th>
                <th class='text-center'>ID</th>
                <th>栏目名称</th>
                <th class='visible-lg'>栏目链接</th>
                <th class='text-center'>状态</th>
                <th class='text-center'>操作</th>
            </tr>
        </thead>
        <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td'>
                    <input class="list-check-box" value='{$vo.ids}' type='checkbox'/>
                </td>
                <td class='list-table-sort-td'>
                    <input name="_{$vo.id}" value="{$vo.sort}" class="list-sort-input"/>
                </td>
                <td class='text-center'>
                    {$vo.id}
                </td>
                <td>{$vo.spl}{$vo.title}</td>
                <td class='visible-lg'>{$vo.url}</td>
                <td class='text-center'>
                    {if $vo.status eq 0}
                    <span>已禁用</span>
                    {elseif $vo.status eq 1}
                    <span style="color:#090">使用中</span>
                    {/if}
                </td>
                <td class='text-center nowrap'>

                    <div class="layui-btn-group">
                        {if $vo.status eq 1 and auth("$classuri/forbid")}
                        <button type="button" data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}' class="layui-btn layui-btn-primary layui-btn-small">禁用</button>
                        {elseif auth("$classuri/resume")}
                        <button type="button" data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}' class="layui-btn layui-btn-primary layui-btn-small">启用</button>
                        {/if}

                        {if auth("$classuri/edit")}
                        <button type="button" data-modal='{:url("$classuri/edit")}?id={$vo.id}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>
                        {/if}

                        {if auth("$classuri/del")}
                        <button type="button" data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>
                        {/if}
                    </div>

                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
</form>

<script>window.form.render();</script>
<script>
    layui.use('form', function(){
        var $ = layui.jquery, form = layui.form;

        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

    });
</script>
{/block}